﻿//
// TravWinController.cs:  Controller component of the MPVC pattern
// This component defines the user interface, processes user input, and dispatches that input to the model.
//
// Copyright 2011-2012 Kasey Osborn (Kasewick@Wordpress.com)
// Ms-PL license - Use and redistribute freely
//

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;

using TravModelSpace;
using TravPresenterAbstraction;
using TravWinViewSpace;


namespace TravWinControllerSpace
{
    public partial class TravWinController : Form
    {
        private TravModel Trav;
        internal bool SupressStatusUpdates = false;
        public Font detailFont { get; private set; }

        // TODO find a better home for column enumerations
        static internal readonly int ColumnType = -2;
        static internal readonly int ColumnSelection = -1;
        static internal readonly int ColumnBaseName = 0;
        static internal readonly int ColumnSize = 1;
        static internal readonly int ColumnRelativePathName = 2;
        static internal readonly int ColumnHash = 3;
        static internal readonly int ColumnFullPathName = 4;
        static internal readonly int ColumnModifyDate = 5;


        public TravWinController ()
        {
            detailFont = new Font ("Courier New", 10, FontStyle.Bold);
            InitializeComponent ();
        }


        private void TravWinController_Shown (object sender, EventArgs e)
        {
            // Set title bar text.
            Text = TravWinAbout.Title;

            // Create the application's model.
            if (WinProgram.Args.Length > 0)
                Trav = new TravModel (WinProgram.Args[0]);
            else
                Trav = new TravModel ();

            // Create the views while injecting them into the model.
            TravWinView wp = new TravWinView (this, Trav);
            IDetailPresenter dp = wp.DetailPresenterFactory (Trav.Detail);

            if (Trav.Arg != null)
                Trav.OpenRootAsync (Trav.Arg);
        }
    }
}
